const Router = require('koa-router')
const fistPage = new Router()
//！拿到前端的数据
//数据库连接池
const pg = require('pg');
let psql = new pg.Pool({
    database: 'running',
    user: 'run',
    port: 5432,
    host: '82.157.94.115',
    password: 'z12345678',
    max: 5
  })


//写对应的接口
// fistPage.get('/content', async ctx => {
//     ctx.body = '首页'
// })
fistPage.get('/content', async ctx => {
    // ctx.body = '首页文章推荐'
    let searchContentPostgresql = `select * from content`;
    let content = await psql.query(searchContentPostgresql);
    // new Promise((resolve, reject) => {
    //     return psql.query(searchContentPostgresql, (err, data) => {
    //         if (err) {
    //             throw err;
    //         }
    //         resolve(data)
    //     })
    
    // } )
    //!?待补充
})

module.exports = fistPage